pub mod ho_bytes {
    #[derive(Clone)]
    #[derive(Debug)]
    pub struct HoBytes {
        hvec: Vec<u8>
    }
    impl HoBytes {
        #[allow(dead_code)]
        pub fn new() -> HoBytes {
            return HoBytes {
                hvec: Vec::new()
            };
        }
        #[allow(dead_code)]
        pub fn push_byte(&mut self, b: u8) {
            self.hvec.push(b);
        }
        #[allow(dead_code)]
        pub fn push_bytes(&mut self, bytes: &[u8]) {
            let len: usize = bytes.len();
            for i in 0..len {
                self.hvec.push(bytes[i]);
            }
        }
        #[allow(dead_code)]
        pub fn length(&self) -> usize {
            return self.hvec.len();
        }
        #[allow(dead_code)]
        pub fn to_bytes(&self) -> &[u8] {
            return self.hvec.as_slice();
        }
        #[allow(dead_code)]
        pub fn split_byte(&self, b: u8) -> Vec<Vec<u8>> {
            let mut v: Vec<Vec<u8>> = Vec::new();
            if self.length() == 0 {
                return v;
            }
            let mut item: Vec<u8> = Vec::new();
            for i in 0..self.length() {
                match self.hvec.get(i) {
                    Some(x) => {
                        if *x == b {
                            item.push(b);
                            v.push(item.clone());
                            item = Vec::new();
                        } else {
                            item.push(*x);
                        }
                    },
                    None => break
                }
            }
            if item.len() > 0 {
                v.push(item.clone());
            }
            return v;
        }
        #[allow(dead_code)]
        pub fn trim(&mut self) {
            loop {
                if self.length() == 0 {
                    break;
                } else {
                    if let Some(u) = self.hvec.get(0) {
                        let x: u8 = *u;
                        if x == ' ' as u8 || x == '\t' as u8 ||
                            x == '\r' as u8 || x == '\n' as u8 {
                            self.hvec.remove(0);
                        }
                    } else {
                        break;
                    }
                }
            }
            loop {
                if self.length() == 0 {
                    break;
                } else {
                    if let Some(u) = self.hvec.get(self.length() - 1) {
                        let x: u8 = *u;
                        if x == ' ' as u8 || x == '\t' as u8 ||
                            x == '\r' as u8 || x == '\n' as u8 {
                            self.hvec.pop();
                        }
                    } else {
                        break;
                    }
                }
            }
        }
    }
}

